<!DOCTYPE html>
<html>
<head>
	<title>go websocket</title>
	<meta charset="utf-8" />  
</head>
<body>
	<script type="text/javascript">
		var wsUri ="ws://localhost:8080/ws"; 
	    
	    function init() { 
	        testWebSocket(); 
	    }  
	 
	    function testWebSocket() { 
	        websocket = new WebSocket(wsUri); 
	        websocket.onopen = function(evt) { 
	            onOpen(evt) 
	        }; 
	        websocket.onclose = function(evt) { 
	            onClose(evt) 
	        }; 
	        websocket.onmessage = function(evt) { 
	            onMessage(evt) 
	        }; 
	        websocket.onerror = function(evt) { 
	            onError(evt) 
	        }; 
	    }  
	 
	    function onOpen(evt) { 
	        document.getElementById("output").innerHTML=("CONNECTED"); 

	    }  
	 
	    function onClose(evt) { 
	        document.getElementById("output").innerHTML=("DISCONNECTED"); 
	    }  
	 
	    function onMessage(evt) { 
			document.getElementById("output").innerHTML=('<span style="color: blue;">websocket行情: '+ evt.data+'</span>'); 
	       // websocket.close(); 
	    }  
	 
	    function onError(evt) { 
	        document.getElementById("output").innerHTML=('<span style="color: red;">ERROR:</span> '+ evt.data); 
	    }  
	 
	    window.addEventListener("load", init, false);  

	</script>

	<div id="output"></div> 	
	
</body>
</html>